<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@include file="/res/include/base-head.jsp"%>
<%@include file="/res/include/jquery-easyui.jsp"%>
<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/community/communityBase.js"></script>
</head>
<body>
	<div class="form_item">
		<dl>
			<dt>社区创建者：</dt>
			<dd>
				<c:out value='${communityBaseVo.creatorNick}' />
			</dd>
		</dl>
		<dl>
			<dt>社区名称：</dt>
			<dd>
				<c:out value='${communityBaseVo.name}' />
			</dd>
		</dl>
		<dl>
			<dt>订单提醒手机号：</dt>
			<dd>
				<input class="txt" id="orderPhone" name="orderPhone" value="${communityBaseVo.orderPhone}"/>
			</dd>
		</dl>
		<dl>
			<dt>社区地址：</dt>
			<dd>
				<c:out value='${communityBaseVo.address}' />
			</dd>
		</dl>
		<dl>
			<dt>社区地图：</dt>
			<dd>
				<img
					src="http://api.map.baidu.com/staticimage?center=${communityBaseVo.x},${communityBaseVo.y}&width=640&height=350&zoom=18&qq-pf-to=pcqq.group&markers=${communityBaseVo.x},${communityBaseVo.y}" />
			</dd>
		</dl>
		<dl>
			<dt>社区图片：</dt>
			<dd>
				<ul class="product_imglist img_imglist">
					<c:forEach items="${listImgs}" var="item" varStatus="i">
						<li><a href="javascript:;" class="item" id="pic${i.index}" onclick="admin.communityBase.addImg('pic${i.index}')">
						<p class="img"><img src="${item}" alt="" /></p>
						</a>
						<input value="删除" class="icon_serach" onclick="delImg(${i.index});" type="button"/>
						</li>
					</c:forEach>
					<c:forEach begin="${fn:length(listImgs)}" end="4" varStatus="i">
						<li><a href="javascript:;" class="item" id="pic${i.index}" onclick="admin.communityBase.addImg('pic${i.index}')">添加图片</a>
						</li>
					</c:forEach>
				</ul>
				<em class="p0">上传4:3的JPG/PNG/BMP图片，建议：720*540px</em>
			</dd>
		</dl>
		<dl>
			<dt>简介：</dt>
			<dd>
				<textarea class="txt grid-75" id="resume" name="resume" oninput="admin.communityBase.netMsgChange('resume',560)" onpropertychange="admin.communityBase.netMsgChange('resume',560)" rows="6" >${communityBaseVo.resume}</textarea>
			</dd>
		</dl>
		<p class="page_btn">
			<input type="button" value="保存" class="btn_blue" onclick="doSave();" />
		</p>
	</div>
<script type="text/javascript">
	function delImg(id){
		$("#pic"+id).html("添加图片");
	}
	//提交保存
	var isSave = false;
	function doSave() {
		var img = "";
		var imglist = $(".img_imglist img");
		if (imglist && imglist.length > 0) {
			imglist.each(function() {
				if (img == "") {
					img += $(this).attr("src").replace(imgFilePath, "");
				} else {
					img += ";" + $(this).attr("src").replace(imgFilePath, "");
				}
			});
		} else {
			top.showInfo('请上传产品图片');
			return;
		}
		var url = contextPath + '/community/base/updateImg';
		if (isSave) {
			return;
		}
		isSave = true;
		var data = {};
		data.imgPath = img;
		data.id = '${communityBaseVo.id}';
		data.resume = $("#resume").val();
		data.orderPhone = $("#orderPhone").val();
		$.post(url, data, function(result) {
			if (result.code == 1) {
				top.showInfo('保存成功');
				top.addTab("",'社区列表', contextPath+'/community/base/list');
			} else {
				isSave = false;
				top.showInfo('保存失败:' + result.msg);
			}
		}, 'json');
	}
</script>
</body>
</html>
